<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* 清除默认样式 */
        * {
            padding: 0;
            margin: 0;
            list-style: none;
    
        }
    
        .list {
            width: 200px;
            height: 200px;
            margin: 100px auto;
            transform: rotate(0deg);
        }
    
        li {
            width: 100px;
            height: 100px;
            background-color: rgb(235, 30, 177);
            float: left;
        }
    
        li:first-child,
        li:last-child {
            border-radius: 0px 200px 0px 200px;
        }
    
        li:nth-child(2),
        li:nth-child(3) {
            border-radius: 200px 0 200px 0;
        }
    </style>
</head>
<body>
       <!-- 
        需求：风车 自动旋转  想停止就能停止

     -->
     <ul class="list">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
    <button id="rotateBtn">转起来</button>
    <button id="stopBtn">停下来</button>
    <script>
        /* 今晚总结获取元素的六种方式
        写纸上

        */
        console.log(rotateBtn);
        var list = document.querySelector('.list');
        var rotateBtn = document.querySelector('#rotateBtn');
        var stopBtn = document.querySelector('#stopBtn');
        var num = 0;
        var timer;
        rotateBtn.onclick = function () {
            // clearInterval(timer);
            // 转起 循环定时器走了
            timer = setInterval(function () {
                num++;
                list.style.transform = 'rotate(' + num + 'deg)';
            }, 30)
        }

        // 停止 定时器清除了
        stopBtn.onclick = function () {
            clearInterval(timer);
        }


    </script>
</body>
</html>